package cn.edu.bjut.homework.chapter7;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class BorderFlowLayoutTester {
	private JFrame frm;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					BorderFlowLayoutTester window = new BorderFlowLayoutTester();
					window.frm.setVisible(true);
					window.frm.pack();
					window.frm.setLocationRelativeTo(null); 
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public BorderFlowLayoutTester() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frm = new JFrame();
		frm.setTitle("混合布局");
		frm.setBounds(100, 100, 527, 325);
		frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frm.getContentPane().setLayout(new BorderLayout(5, 5));

		JButton btnNorth = new JButton("NORTH");
		frm.getContentPane().add(btnNorth, BorderLayout.NORTH);

		JButton btnWest = new JButton("WEST");
		frm.getContentPane().add(btnWest, BorderLayout.WEST);

		JButton btnEast = new JButton("EAST");
		frm.getContentPane().add(btnEast, BorderLayout.EAST);

		JButton btnSouth = new JButton("SOUTH");
		frm.getContentPane().add(btnSouth, BorderLayout.SOUTH);
		
		JPanel panel = new JPanel();
		frm.getContentPane().add(panel, BorderLayout.CENTER);
		
		JButton[] buttons = new JButton[9]; 
		for (int i = 0; i < 9; i++) {
			buttons[i] = new JButton(String.valueOf(i)); 
			panel.add(buttons[i]);
		}	
	}
}